home *** CD-ROM | disk | FTP | other *** search
- /*
- * the class PLACE_LINE
- * Copyright (C) 1996, 1997 Kazutaka Hirata <khirata@jove.acs.unt.edu>
- */
-
- #include "../stdafx.h"
-
- #include "../common/bool.h"
-
- #include "plline.h"
-
- void PLACE_LINE::PLACE_LINE_MOUSE_CURSOR::draw_cursor_core(KBAN_DRAW& draw, const LINE_ELEMENT& target)
- {
- draw.draw_primitive_line_cursor(target);
- }
-
- STAGE* PLACE_LINE::init_new(KBAN_INFO& info, KBAN_DRAW& draw)
- {
- return new STAGE_INITIAL;
- }
-
- const char* PLACE_LINE::get_name(void)
- {
- return "Place:Line";
- }
-
- STAGE* PLACE_LINE::STAGE_INITIAL::mouse_left_up(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
- {
- XY ac;
- info.grid().xy_pc2ac(pc, ac);
- return new STAGE_PLACE_LINE(ac);
- }
-
- STAGE* PLACE_LINE::STAGE_INITIAL::mouse_right_up(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
- {
- return NULL;
- }
-
- PLACE_LINE::STAGE_PLACE_LINE::STAGE_PLACE_LINE(const XY& ac_s)
- : m_ac_s(ac_s) {}
-
- STAGE* PLACE_LINE::STAGE_PLACE_LINE::init(KBAN_INFO& info, KBAN_DRAW& draw)
- {
- info.bCaptured() = true;
- return this;
- }
-
- STAGE* PLACE_LINE::STAGE_PLACE_LINE::pre_redraw(KBAN_INFO& info, KBAN_DRAW& draw)
- {
- // m_mcur.erase_cursor(draw);
- return this;
- }
-
- STAGE* PLACE_LINE::STAGE_PLACE_LINE::redraw(KBAN_INFO& info, KBAN_DRAW& draw)
- {
- m_mcur.redraw_cursor(draw);
- return this;
- }
-
- STAGE* PLACE_LINE::STAGE_PLACE_LINE::mouse_move(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
- {
- XY ac_e;
- info.grid().xy_pc2ac(pc, ac_e);
- LINE_ELEMENT current(m_ac_s, ac_e, info.apt_line().width());
- m_mcur.draw_cursor(draw, current);
- return this;
- }
-
- STAGE* PLACE_LINE::STAGE_PLACE_LINE::mouse_left_up(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
- {
- m_mcur.erase_cursor(draw);
-
- XY ac_e;
- info.grid().xy_pc2ac(pc, ac_e);
-
- STAGE* ret;
-
- if(m_ac_s != ac_e) {
- PRIMITIVE& primitive = info.kban_data().primitive();
- LINE_LIST& line_list = primitive.layer(info.active_layer().get()).line_list();
-
- LINE_ELEMENT line_element(m_ac_s, ac_e, info.apt_line().width());
- line_list.push_back(line_element);
- info.SetModifiedFlag();
- info.new_state().set(true);
- info.new_state_str() = "Place Line";
-
- draw.draw_primitive_line(line_element, info.active_layer().get());
-
- info.bCaptured() = false;
- ret = new STAGE_PLACE_LINE(ac_e);
- } else {
- AfxGetMainWnd()->MessageBox("Origin and destination are the same point.", "Place Line");
-
- ret = this;
- }
- return ret;
- }
-
- STAGE* PLACE_LINE::STAGE_PLACE_LINE::mouse_right_up(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
- {
- m_mcur.erase_cursor(draw);
- info.bCaptured() = false;
- return new STAGE_INITIAL;
- }
-
- void PLACE_LINE::STAGE_PLACE_LINE::end(KBAN_INFO& info, KBAN_DRAW& draw)
- {
- m_mcur.erase_cursor(draw);
- info.bCaptured() = false;
- }
-